﻿using CID.Domain.Development;
using CID.Domain.Infrastructure;
using CID.Domain.Operations;
using CID.Domain.Users;

namespace CID.Domain.Persistence.Mappings.Development
{
    public class ComponentMap : DescribedEntityMap<Component>
    {
        public ComponentMap() : base()
        {
            Map(x => x.Enabled);
            HasOne<ActivationDeactivationDefinition>(x => x.ActivationDeactivationDefinition).Cascade.All().PropertyRef(x => x.Component) ;
            References<ServerRole>(x => x.RequiredServerRole).Column("ServerRole_id");
            References<User>(x => x.Responsible);
            HasMany<Version>(x => x.Versions);
            HasManyToMany<Version>(x => x.Dependants).Table(VersionMap.DependenciesMapTable).Inverse();
        }
    }
}
